home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Copyright (C) 1997-1998 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // $Source: /vobs/aw/Maya/src/RenderUISlice/UI/scripts/hypergraphMaterialMenu.mel $
- //
- // $Author: awoo $
- // $Revision: /main/7 $
- // $Date: 2000/01/18 20:38:25 $
- //
-
- //
- // Create context sensitive Hypergraph menu for shader nodes
- // This is displayed with RMB on shader nodes
- //
- global proc hypergraphMaterialMenu(string $editor, string $menu, string $node)
- {
- // The visor uses a hyper graph panel, so the only way to tell
- // that we are in the visor is by the name
- //
- int $isVisor = gmatch( $editor, "*VisorEd" );
-
- setParent -m $menu;
- menu -edit -deleteAllItems $menu;
-
- menuItem
- -l ("Material: " + $node)
- MaterialMenuTitleItem;
- menuItem -divider true;
- menuItem -divider true;
- if (!$isVisor)
- {
- menuItem
- -l "Graph Shader Network"
- -c ("hyperShade -shaderNetwork "+$node+" "+$editor)
- MaterialUpstreamItem;
- }
- menuItem -divider true;
-
- string $shadingGroupArray[] =
- `listConnections
- -source false
- -destination true
- -type "shadingEngine"
- $node`;
-
- int $isOceanShader = nodeType( $node ) == "oceanShader";
- int $groupSize = size($shadingGroupArray);
- if( $groupSize == 2 && $isOceanShader){
- // OceanShaders are assigned twice to the same group:
- // once for displacement and once for surfaceShading.
- // Thus we get two identical groups, while we wish to display
- // just one.
- if( $shadingGroupArray[0] == $shadingGroupArray[1] ){
- $groupSize = 1; // force use of "assign material"
- }
- }
-
- if( $groupSize <= 1)
- {
- if( $isOceanShader ){
- menuItem
- -l "Assign Material To Selection"
- -c ("assignOceanShader " + $node)
- MaterialAssignItem;
- }
- else
- {
- menuItem
- -l "Assign Material To Selection"
- -c ("hyperShade -assign " + $node)
- MaterialAssignItem;
- }
- menuItem -divider true;
- menuItem -l "Select Objects With Material"
- -c ("hyperShade -objects " + $node)
- MaterialShowObjectsItem;
- menuItem -l "Frame Objects With Material"
- -c ("hyperShade -objects " + $node + ";fitAllPanels -selected")
- MaterialFrameObjectsItem;
- }
- else
- {
- int $i;
-
- for ($i = 0; $i < size($shadingGroupArray); $i++)
- {
- menuItem
- -l ("Assign " + $shadingGroupArray[$i] + " To Selection")
- -c ("hyperShade -assign " + $shadingGroupArray[$i]);
- }
- menuItem -divider true;
-
- for ($i = 0; $i < size($shadingGroupArray); $i++)
- {
- menuItem
- -l ("Select Objects in " + $shadingGroupArray[$i])
- -c ("hyperShade -objects " + $shadingGroupArray[$i]);
- menuItem
- -l ("Frame Objects in " + $shadingGroupArray[$i])
- -c ("hyperShade -objects "
- + $shadingGroupArray[$i]
- + ";fitAllPanels -selected");
- }
- }
- menuItem -divider true;
- menuItem
- -l "Attribute Editor..."
- -c ("hyperGraph -e -attributeEditor single -useFeedbackList " + $editor)
- SingleAttrEditorItem;
- menuItem -l "Rename"
- -c ("hyperGraph -e -rename -useFeedbackList " + $editor)
- RenameItem;
- }
-